#pragma once

#include <Windows.h>
#include <d3d9.h>
#include <d3dx9.h>
#include <vector>

#pragma comment(lib, "d3d9.lib")

namespace LSH_D3D9{

//typedef std::vector<IDirect3DSwapChain9*> SwapChainSet;
//typedef std::vector<IDirect3DSwapChain9*>::iterator SwapChainSetItr;
//typedef std::vector<IDirect3DSwapChain9*>::const_iterator SwapChainSetItrC;

class D3D9Device{
public:
    D3D9Device(void);
    ~D3D9Device(void);
public:
    bool Initialize(HWND hwnd, BOOL windowed, UINT width, UINT height, UINT depth);
	void Shutdown();
public:
	inline IDirect3DDevice9* GetDevice() { return _pD3dDevice; }
	inline const D3DCAPS9& GetDeviceCaps() { return _deviceCaps; }
	//inline const SwapChainSet& GetSwapChainSet() { return _swapChainSet; }
public:
	void BeginSence();
	void EndSence();
	void Present();
public:
	void BeginSence(int swapChainIndex);
	void EndSence(int swapChainIndex);
	void Present(int swapChainIndex);
protected:
	void getDeviceCaps();
	void getDevicePresent();
protected:
	HWND					_hwnd;

	BOOL					_windowed;
	UINT					_width;
	UINT					_height;
	UINT					_depth;

    LPDIRECT3D9             _pD3d; 
    LPDIRECT3DDEVICE9       _pD3dDevice;

    D3DCAPS9			    _deviceCaps;
	D3DPRESENT_PARAMETERS	_devicePresentParam;	

    LPDIRECT3DSWAPCHAIN9    _pD3dSwapChain;
	//SwapChainSet			_swapChainSet;
};

}
